#ifndef BASEMODULE_H
#define BASEMODULE_H

#include "moduleid.h"
#include <QObject>
#include <QMutex>
#include "moduleconfigdefine.h"

class BaseModule : public QObject
{
    Q_OBJECT
public:
    BaseModule(QObject *parent = nullptr);
    virtual ~BaseModule();

    uint getMagic();

    virtual bool setConfig(int id, QVariant &var);
    virtual bool getConfig(int id, QVariant &var);

    virtual bool setParam(int id, QVariant &var);
    virtual bool getParam(int id, QVariant &var);

    void setID(ModuleID id);
    ModuleID getID(void);

    void setName(const QString &name);
    QString getName() const;

    void setEnable(bool en);
    bool getEnable() const;

public slots:
    virtual void onStart() = 0;

signals:
    void moduleEvent(int id, const QVariant &data);

protected:
    QMutex		*m_mutex = nullptr;
    ModuleID 	m_id = ModuleID_Unknown;
    QString		m_name;
    bool        m_enable = true;
};

#endif // BASEMODULE_H
